/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.liwalo.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Carlos
 */
@Entity
@Table(name = "valor")
@NamedQueries({
    @NamedQuery(name = "Valor.findAll", query = "SELECT v FROM Valor v")})
public class Valor implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "nombre")
    private String nombre;
    @Basic(optional = false)
    @Column(name = "unidades")
    private int unidades;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "valorId", fetch = FetchType.LAZY)
    private List<ProductosPedido> productosPedidoList;
    @JoinColumn(name = "atributo_id", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Atributo atributoId;

    public Valor() {
    }

    public Valor(Integer id) {
        this.id = id;
    }

    public Valor(Integer id, String nombre, int unidades) {
        this.id = id;
        this.nombre = nombre;
        this.unidades = unidades;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public int getUnidades() {
        return unidades;
    }

    public void setUnidades(int unidades) {
        this.unidades = unidades;
    }

    public List<ProductosPedido> getProductosPedidoList() {
        return productosPedidoList;
    }

    public void setProductosPedidoList(List<ProductosPedido> productosPedidoList) {
        this.productosPedidoList = productosPedidoList;
    }

    public Atributo getAtributoId() {
        return atributoId;
    }

    public void setAtributoId(Atributo atributoId) {
        this.atributoId = atributoId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Valor)) {
            return false;
        }
        Valor other = (Valor) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.liwalo.entities.Valor[ id=" + id + " ]";
    }
    
}
